package com.smart.campus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.campus.dao.ShAttendanceDetailsMapper;
import com.smart.campus.dto.ShAttendanceDetails;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.service.ShAttendanceDetailsService;
import com.smart.campus.util.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: smart-campus
 * @BelongsPackage: com.smart.campus.service.impl
 * @Author: 戴冰洁
 * @CreateTime: 2024-10-07  19:44
 * @Description: TODO
 * @Version: 1.0
 */
@Service
public class ShAttendanceDetailServiceImpl implements ShAttendanceDetailsService {
    @Autowired
    private ShAttendanceDetailsMapper shAttendanceDetailsMapper;

    @Override
    public List<ShAttendanceDetails> findattendlist() {
        return shAttendanceDetailsMapper.selectList(null);
    }

    @Override
    public void addattend(ShAttendanceDetails shAttendanceDetails) {
        shAttendanceDetailsMapper.insert(shAttendanceDetails);
    }

    @Override
    public void daleteattend(Integer id) {
        shAttendanceDetailsMapper.deleteById(id);
    }

    @Override
    public PagedResponse<ShAttendanceDetails> attendById(ShAttendanceDetails shAttendanceDetails, Integer pageSum, Integer pageSize) {
        Page<ShAttendanceDetails> shAttendanceDetailsPage = new Page<>(pageSum, pageSize);
        QueryWrapper<ShAttendanceDetails> shAttendanceDetailsQueryWrapper = new QueryWrapper<>();
        Page<ShAttendanceDetails> shAttendanceDetailsPage1 = shAttendanceDetailsMapper.selectPage(shAttendanceDetailsPage, shAttendanceDetailsQueryWrapper);
        return PaginationUtil.getPaginationResponse(shAttendanceDetailsPage1.getRecords(),pageSum,pageSize,shAttendanceDetailsPage1.getTotal());
    }

    @Override
    public ShAttendanceDetails attenList(Integer id) {
        return shAttendanceDetailsMapper.selectById(id);
    }

    @Override
    public void updateattend(ShAttendanceDetails shAttendanceDetails) {
        shAttendanceDetailsMapper.updateById(shAttendanceDetails);
    }
}
